#!/usr/bin/env python3
# -*- coding: utf-8 -*-

b = bytes.fromhex

s_name =  "NGEE 161FCH~16420H	007 Goldeneye (USA)"
sample = b("""27BDFFD0 3C0E8006 25CE7D30 AFBF0014 AFA40030 AFA50034 AFA0002C AFAE0024
              AFA00028 8FAF0028 8FB90028 3C018006 000FC080 00380821 AC207D30 27280001
              29010010 1420FFF7 AFA80028 3C0A8006 24090001 3C018006 254A7D30 AC297D6C
              AFAA0024 AFA00028 8FAB0024 A1600000 8FAE0028 8FAC0024 25CF0001 29E10004
              258D0001 AFAF0028 1420FFF7 AFAD0024 241800FF 24190001 24080003 240900FF
              240A00FF 240B00FF 240C00FF A3B8001C A3B9001D A3A8001E A3A0001F A3A90020
              A3AA0021 A3AB0022 A3AC0023 27AE001C 8DC10000 8FAD0024 240A00FE 3C058006
              A9A10000 B9A10003 8DD90004 24A57D30 24040001 A9B90004 B9B90007 8FA80024
              25090008 AFA90024 0C0057B4 A12A0000 AFA2002C 8FA40030 00002825 0C003774
              24060001 240B0005 3C018006 3C058006 A02B7CE0 24A57D30 0C0057B4 00002025
              AFA2002C 8FA40030 00002825 0C003774 24060001 8FAC002C 11800003 00000000
              1000002C 01801025 3C188006 27187D30 AFB80024 AFA00028 8FAF0024 A1E00000
              8FB90028 8FAD0024 27280001 29010004 25AE0001 AFA80028 1420FFF7 AFAE0024
              8FA90024 27AA001C 89210000 99210003 AD410000 892C0004 992C0007 AD4C0004
              93B8001E 8FAE0034 330F00C0 000F6903 A1CD0003 93B90021 93AB0020 8FA90034
              00194200 010B5025 A52A0000 8FB80034 93AC0022 A30C0002 8FAF0034 91ED0003
              11A00003 00000000 10000002 01A01025 00001025 8FBF0014 27BD0030 03E00008
              00000000""")

s_mask = b("""FFFFFFFF FFFF0000 FFFF0000 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFF0000 FFFFFFFF FFFFFFFF FFFF0000 FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFF0000 FFFFFFFF FFFF0000 FFFF0000 FFFF0000
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFF0000
              FFFFFFFF FFFFFFFF FFFFFFFF FFFF0000 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF 00000000 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF 00000000
              FFFFFFFF FFFFFFFF FFFF0000 FFFF0000 FFFF0000 FFFF0000 00000000 FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF 00000000 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFF0000 FFFF0000 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
              FFFFFFFF""")

symbol = (('+', 'V0 = errors reading EEPROM status to A1 using queue A0', 0x6FFFF400),
          ('+', 'generic: V0 = errors sending SI buffer A1 using queue A0', 0xB0 + 0x6FFFF400),
          )

# 0x100 of 0x224; embeds generic SI W/R at +0xB0
p_data = b("""3C038000 8C610388 54200021 8C620360 27BDFFE0 AFBF001C AFA40020 AFA50024
              3C050000 24060001 2401FFFE ACA00000 ACA6003C 3C03FF01 24630300 ACA10008
              ACA30004 3C060000 A0C10000 00000000 24A50000 3C050000 1440000A 90A30006
              8FA70024 90A10008 90A20009 90A6000A A0E20000 A0E10001 A0E60002 00031102
              A0E20003 8FBF001C 03E00008 27BD0020 2C430800 2C420001 3C04C000 00431821
              00640804 00001025 03E00008 ACA10000 

              27BDFFE0 AFBF001C AFA40020 AFA50024 24040001 00000000 AFA40018 AFA20014
              8FA40020 00002825 00000000 24060001 8FA20018 2444FFFF 5440FFF6 8FA50024
              8FBF001C 8FA20014 03E00008 27BD0020""")

p_cmds = ((0x22, 0x6, 2),
          (0x2E, 0xA, 2),
          ('+', 0x32, 0xA, 2),
          ('+', 0x3E, 0xA, 2),
          ('+', 0x42, 0xA, 2),
          (0x46, 0x12A, 2),
          (0x4A, 0x132, 2),
          ('L', 0x4C, 'generic: V0 = errors sending SI buffer A1 using queue A0', 4),
          (0x52, 0xA, 2),
          (0x56, 0x6, 2),
          ('+', 0x5E, 0xA, 2),
          ('+', 0x66, 0xA, 2),
          ('+', 0x6A, 0xA, 2),
          ('+', 0x6E, 0xA, 2),
          # w/i 'generic: V0 = errors sending SI buffer A1 using queue A0'
          (0xC4, 0x108, 4),
          (0xD8, 0x11C, 4),
          )
